<!--main content-->


<?php
if (!$this->cart->contents()):
    echo '<h3 class="alt"><span>' . __('you_do_not_have_any_items_yet') . '</span></h3>';
    echo '<p><div class="col-1"><a href="'.base_url().'">Continue shopping</a></div></p>';
else:
    echo '<h3 class="alt" id="yscart"><span>' . __('your_shopping_cart') . '</span></h3>';
    ?>

    <?php echo form_open(site_url('checkout-order'), array('id' => 'shopping_cart')); ?>

    <div class="wrapper">
        <table border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td><h5><?php echo __('quantity'); ?></h5></td>
                <td><h5><?php echo __('item'); ?></h5></td>
                <td><h5><?php echo __('price'); ?></h5></td>
                <td><h5><?php echo __('sub_total'); ?></h5></td>
                <td></td>
            </tr>

            <?php foreach ($this->cart->contents() as $items): ?>
                <tr id="tr_<?php echo $items['rowid'];?>">
                    <td>
                        <span class="txt1">
                            <?php
                            //echo form_hidden('rowid', $items['rowid']);
                            echo form_input(array('name' => $items['rowid'], 'value' => $items['qty'], 'maxlength' => '3', 'size' => '15', 'class' => 'text cart_quantity_input'));
                            ?>
                        </span>
                    </td>
                    <td>
                        <span class="txt1">
                            <?php echo $items['name']; ?>
                        </span>
                    </td>
                    <td>
                        <span class="txt1" id="price<?php echo $items['rowid'];?>">
                            <?php echo __('&dollar;') . '&nbsp;' . $this->cart->format_number($items['price']); ?>
                        </span>
                    </td>
                    <td>
                        <span class="txt1" id="subtotal<?php echo $items['rowid'];?>">
                            <?php echo __('&dollar;') . '&nbsp;' . $this->cart->format_number($items['subtotal']); ?>
                        </span>
                    </td>
                    <td>
                        <a href="<?php echo $items['rowid'];?>" class="cart_delete"><img src="<?php echo site_url('assets/images/cross.png');?>" /></a>
                    </td>
                </tr>
            <?php endforeach; ?>

        </table>
    </div>

    <div style="clear: both;">&nbsp;</div>

    <div class="wrapper">
        <div class="col-1" ><span class="txt1">&nbsp;</span></div>
        <div class="col-2" ><span class="txt1">&nbsp;</span></div>
        <div class="col-3" ><h5><?php echo __('total'); ?></h5></div>
        <div class="col-4" id="alltotal"><strong><?php echo __('&dollar;') . '&nbsp;' . $this->cart->format_number($this->cart->total()); ?></strong></div>
    </div>

    <div class="wrapper">
        <div class="col-1"><?php echo form_button('', __('continue_shopping'), 'onClick="continue_shopping();"');//echo form_button('', __('update_cart'),'onClick="update_cart();"'); ?></div>
        <div class="col-2"><?php //echo form_button('', __('continue_shopping'), 'onClick="continue_shopping();"'); ?></div>
        <div class="col-3"><?php echo form_button('', __('empty_cart'), 'onClick="empty_cart();"'); ?></div>        
        <div class="col-4"><?php echo form_submit('', __('checkout_cart'));//form_button('', __('checkout_cart'), 'onClick="checkout_cart();"'); ?></div>
    </div>

    <?php echo form_close(); ?>

<?php endif; ?>

<div style="clear: both;">&nbsp;</div>

<!--/main content-->
<script type="text/javascript" src="<?php echo site_url('assets/jquery/jquery-typewatch.pack.js')?>"></script>
<script type="text/javascript" src="<?php echo site_url('assets/jquery/ajax.cart.js')?>"></script>
<script type="text/javascript">
   // site_url('shopping/update-cart#yscart')
    function empty_cart(){
        //        alert('Empty cart function should be called');
        location.href = '<?php echo site_url('shopping/empty-cart'); ?>';
    }
    
    function continue_shopping(){
        //        alert('Continue shopping function should be called');
        location.href = '<?php echo base_url(); ?>';
    }
    
    /*function udpate_cart(){
        $.ajax({
                type: 'POST',
                url: Gidaff.SITE_URL + '/order/do_add_cart',
                data: {
                    'id_product' : id_product,
                    'product_name' : product_name,
                    'image_name' : image_name,
                    'quantity' : quantity,
                    'price' : price
                },
                success: function(data)                          
                {     
                    $('#cart_count').html(data);                            
                    alert('Ban da them '+quantity+' san pham vao gio hang');
                }
            });
    }
    
    function checkout_cart(){
//        alert('Checkout cart function is under construction');
//        $('#shopping_cart').attr('action', '/paypal/auto_form');
        //alert('hello');
        $('#shopping_cart').attr('action', '<?php echo site_url('checkout-order');?>');
        alert($('#shopping_cart').attr('action'));
        $('#shopping_cart').submit();
    }*/
    
</script>
